
package gui;

import bluetooth.Peer;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Gauge;

/**
 *
 * @author alquad
 */
public class DiscoveryAlert extends Alert implements Runnable {

    private Gauge progressBar;
    private Peer deviceDiscovery;

    public DiscoveryAlert(String title, Peer deviceDiscovery)
    {
        super(title);
        //setString(deviceDiscovery.getMensaje());
        setString(deviceDiscovery.darArchivosCompartidos());
        this.deviceDiscovery=deviceDiscovery;
        
    }

    public void doAlert()
    {
        progressBar = new Gauge( null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING );
        setIndicator( progressBar );
        setTimeout(FOREVER);
    }

    public void run()
    {
        doAlert();
        while(!deviceDiscovery.isIsReady())
        {
            try
            {
                setString(deviceDiscovery.getMensaje());
                System.out.println(deviceDiscovery.getMensaje());
                System.out.println(getString());
                new Thread().sleep(100);
            }
            catch(Exception e){}
        }
        setTimeout(1000); // tiempo en milisegundos.
    }

}
